﻿using System;
using System.Collections.Generic;

using System.Text;
using ITAP.ShprossesBuilder.Info;
using ITAP.ShprossesBuilder.Modelling.Components;
using ITAP.ShprossesBuilder.Modelling;
using System.Drawing;
using ITAP.Core.Modelling;

namespace ITAP.ShprossesBuilder.Editor
{
    public enum Material
    {
        ShprossConnector,
        Shpross,
        SnapOnCap, 
        SpacerConnector
    }

    public class FakeProfileProvider
    {
        private List<Material> materials;
        public FakeProfileProvider()
        {
//            this.materials = new List<Material>(materials);
        }

        public ProfilesInfo GetInfo(Material[] materials)
        {
            this.materials = new List<Material>(materials);
            ProfilesInfo info = new ProfilesInfo();
            SpacerConnector defaultSpacerConnector = ComponentFactory.CreateSpacerConnector(4, 8, 1, new ModelPoint(0, 0), new ModelVector(1, 1), SpacerConnectorType.Internal, "Соединитель в рамку 1", Color.White, Color.Black, 0, new int[] { 0 });

            if (this.materials.Contains(Material.SpacerConnector))
            {                
                info.SpacerConnectors.Add(ComponentFactory.CreateSpacerConnector(4, 8, 1, new ModelPoint(0, 0), new ModelVector(1, 1), SpacerConnectorType.Internal, "Соединитель в рамку 1", Color.White, Color.Black, 0, new int[] { 0 }));
                info.SpacerConnectors.Add(ComponentFactory.CreateSpacerConnector(15, 25, 1, new ModelPoint(0, 0), new ModelVector(1, 1), SpacerConnectorType.External, "Соединитель в рамку 2", Color.White, Color.Black, 0, new int[] { 0 }));
            }

            if (this.materials.Contains(Material.ShprossConnector))
            {
                IComponent connector = ComponentFactory.CreateXConnector(6, 4, 20, 0.001, "Первый коннектор", Color.White, Color.Black, 0, new int[] { 22 });
                connector.UniqueIdsEnabled = false;
                info.Connectors.Add(connector);
                info.Connectors.Add(ComponentFactory.CreateXConnector(4, 6, 15, 0.001, "Второй коннектор", Color.Yellow, Color.Black, 0, new int[] { 0 }));
                info.Connectors.Add(ComponentFactory.CreateTConnector(5, 15, 10, 0.001, "Третий коннектор", Color.LightGray, Color.Black, 0, new int[] {0}));
                info.Connectors.Add(ComponentFactory.CreateTConnector(7, 9, 15, 0.001, "Шестой коннектор", Color.White, Color.Black, 0, new int[] {0}));
                info.Connectors.Add(ComponentFactory.CreateIConnector(7, 9, 20, 0.005, "Восьмой коннектор", Color.LightYellow, Color.Black, 0, new int[] {0}));
                info.Connectors.Add(ComponentFactory.CreateCornerConnector(7, 10, 15, 0.001, "Девятый коннектор", Color.Blue, Color.Black, 0, new int[] {0}));

                info.Connectors.Add(ComponentFactory.CreateYConnector(5, 7, 10, 15, new Angle(Math.PI / 2), 0.001, "Y-коннектор", Color.White, Color.Black, 0, new int[] {0}));
                info.Connectors.Add(ComponentFactory.CreateYConnector(3, 8, 7, 20, new Angle(Math.PI / 3), 0.001, "Y-коннектор 2", Color.Yellow, Color.Black, 0, new int[] {0}));                
                info.Connectors.Add(ComponentFactory.CreateEquilateralTriangleYConnectorBySideLength(3, 8, 20, 0.001, "Y-коннектор 3", Color.Black, Color.Black, 0, new int[] { 0 }));
                info.Connectors.Add(ComponentFactory.CreateEquilateralTriangleYConnectorByStubLength(3, 8, 20, 0.001, "Y-коннектор 4", Color.Black, Color.Black, 0, new int[] { 0 }));                
                info.Connectors.Add(ComponentFactory.CreateHalfSunConnector(5, 7, new Angle[] { new Angle(Math.PI / 4), new Angle(Math.PI / 2), new Angle(3 * Math.PI / 4) }, 0.3, 20, Color.White, Color.Black, "Полу-солнышко 2", 0.001, 0, new int[] { 0 }));
                info.Connectors.Add(ComponentFactory.CreateHalfSunConnector(5, 7, new Angle[] { new Angle(2 * Math.PI / 8), new Angle(3 * Math.PI / 8), new Angle(4 * Math.PI / 8), new Angle(5 * Math.PI / 8), new Angle(6 * Math.PI / 8) }, 0.3, 20, Color.White, Color.Black, "Полу-солнышко 2", 0.001, 0, new int[] { 0 }));
                info.Connectors.Add(ComponentFactory.CreateSunConnector(5, 7, new Angle[] { new Angle(0), new Angle(Math.PI / 4), new Angle(Math.PI / 2), new Angle(3 * Math.PI / 4), new Angle(Math.PI), new Angle(5 * Math.PI / 4), new Angle(6 * Math.PI / 4), new Angle(7 * Math.PI / 4) }, 0.4, 20, Color.White, Color.Black, "Солнышко", 0.001, 0, new int[] { 0 }));

                info.Connectors.Add(ComponentFactory.CreateYConnector(3, 5, 7, 8, new Angle(2 * Math.PI / 3), 0.03, "Y-коннектор 120", Color.White, Color.Black, 0, new int[] { 0 }));
                info.Connectors.Add(ComponentFactory.CreateYConnector(3, 5, 7, 8, new Angle(Math.PI / 3), 0.03, "Y-коннектор 60", Color.White, Color.Black, 0, new int[] { 0 })); 
            }

            if (this.materials.Contains(Material.Shpross))
            {
                IComponent shpross = ComponentFactory.CreateShprossWithSpacerConnectors(7, 0,
                    new ModelPoint(0, 0),
                    new ModelPoint(70, 70),
                    null,
                    null,
                    "Первый профиль", Color.LightYellow, Color.Black, 1, new int[] { 1, 13 });
               // shpross.UniqueIdsEnabled = false;
                info.Shprosses.Add(shpross);
                info.Shprosses.Add(ComponentFactory.CreateShprossWithSpacerConnectors(9, 0, 
                    new ModelPoint(0, 0), 
                    new ModelPoint(100, 0), 
                    (SpacerConnector)defaultSpacerConnector.Clone(), 
                    (SpacerConnector)defaultSpacerConnector.Clone(), 
                    "Второй профиль", Color.White, Color.Black, 0, new int[] { 0 }));

                info.Shprosses.Add(ComponentFactory.CreateShprossWithSpacerConnectors(9, 0,
                    new ModelPoint(0, 0),
                    new ModelPoint(0, 100),
                    (SpacerConnector)defaultSpacerConnector.Clone(),
                    (SpacerConnector)defaultSpacerConnector.Clone(),
                    "Второй профиль", Color.White, Color.Black, 0, new int[] { 0 }));

            }

            if (this.materials.Contains(Material.SnapOnCap))
            {
                IComponent iSnapOnCap = ComponentFactory.CreateISnapOnCap(15, 25, "I-накладка", Color.White, Color.Black, 0.01, 33, new int[] { 44 });
                iSnapOnCap.UniqueIdsEnabled = false;
                info.SnapOnCaps.Add(iSnapOnCap);
                info.SnapOnCaps.Add(ComponentFactory.CreateYSnapOnCap(10, 20, new Angle(Math.PI / 2), "Y-накладка", Color.Gray, Color.Black, 0.01, 0, new int[] { 0 }));
                info.SnapOnCaps.Add(ComponentFactory.CreateCornerSnapOnCap(10, 20, "Уголковая накладка", Color.White, Color.Black, 0.01, 0, new int[] { 0 }));
                info.SnapOnCaps.Add(ComponentFactory.CreateXSnapOnCap(14, 22, "X-накладка", Color.Black, Color.Black, 0.01, 0, new int[] { 0 }));
                info.SnapOnCaps.Add(ComponentFactory.CreateXSnapOnCap(14, 22, "X-накладка 2", Color.White, Color.Black, 0.01, 0, new int[] { 0 }));
                info.SnapOnCaps.Add(ComponentFactory.CreateTSnapOnCap(15, 25, new Angle(Math.PI / 3), "T-накладка 1", Color.Gray, Color.Black, 0.01, 0, new int[] { 0 }));
                info.SnapOnCaps.Add(ComponentFactory.CreateTSnapOnCap(15, 25, new Angle(Math.PI / 2), "T-накладка 2", Color.Gray, Color.Black, 0.01, 0, new int[] { 0 }));
                info.SnapOnCaps.Add(ComponentFactory.CreateTLatchSnapOnCap(15, 20, "T-защёлка", Color.White, Color.Black, 0.01, 0, new int[] { 0 }));
            }
            return info;
        }
    }
}
